/*
 * @Author: szx
 * @Date: 2022-03-04 14:15:22
 * @LastEditTime: 2022-03-04 14:18:36
 * @Description:
 * @FilePath: \leetcode\100-199\113\113_2.js
 */
var pathSum = function (root, targetSum) {
    if (!root) return [];
    const res = [];
    const dfs = function (root, path, targetSum) {
        const target = targetSum - root.val;
        path.push(root.val);
        if (!root.left && !root.right) {
            if (target == 0) res.push(Array.from(path));
            return;
        }
        hasPathSum(root, path, target);
        hasPathSum(root, path, target);
        path.pop();
    };
    return res;
};
